#include "movepiece.h"
#include "model/ChessBoard.h"

MovePiece::MovePiece(const model::Location& from, const model::Location& to, bool capture) :
    from(from), to(to), capt(capture)
{
}

void MovePiece::execute(model::ChessBoard& b)
{
   taken = b.movePiece(from, to);
}

void MovePiece::undo(model::ChessBoard& b)
{
    b.movePiece(to, from);
    taken = b.setPieceAt(to, taken);
}

bool MovePiece::operator ==(const MovePiece& m) const
{
    return from == m.from && to == m.to;
}

bool MovePiece::operator <(const MovePiece& m) const
{
    return to < m.to;
}
